#!/bin/sh

set -e

if lsmod | grep hid_uclogic > /dev/null; then
    rmmod hid_uclogic || true
fi

if lsmod | grep wacom > /dev/null; then
    rmmod wacom || true
fi

if [ $(lsmod | grep -c uinput) -eq 0 ]; then
    modprobe uinput
fi

if udevadm control --reload-rules; then
    udevadm trigger && udevadm settle -t 15 || true
fi

printf "Run the daemon by invoking 'otd-daemon', or by enabling the systemd user service opentabletdriver.service"
